angular.module("crawlerApp").controller("dataTypeCtrl", function ($scope, $http, $state, $stateParams, menuService, $rootScope) {
    getDataType();

    function getDataType() {
        $http.get("crawler/dataFormat/getDataType").then(function (response) {
            $scope.dataType = response.data;
        });

    }

    $scope.commit = function (dataType) {
        //dataFormat.dataType = angular.copy($scope.config.dataType);
         var data={
             "type":dataType.dataType,
             "describe":dataType.dataDescribe
         };
        $http.post("crawler/dataFormat/addDataType", data).then(function (response) {
            getDataType();
        });
    };


    $scope.createMapping = function (data) {

       // $rootScope.data = data;
        $state.go("format", {config: data});
    };

    $scope.delete=function (data) {
        $scope.dataToDelete=data;
    };

    $scope.confirmDelete=function () {
        $http.post("crawler/deleteIndex",$scope.dataToDelete).then(function (response) {
            if(response.status=='200'){
                alert("删除成功！");
            }
            getDataType();
        });
    }
});